package com.hundsun.cprs.yyt.service.trade.dao;

import java.util.List;

import com.hundsun.cprs.yyt.service.trade.domain.EntrustImportLog;
import com.hundsun.cprs.yyt.service.trade.dto.AuditRequest;
import org.apache.ibatis.annotations.Param;

import com.hundsun.cprs.yyt.service.trade.domain.TradeEntrust;
import com.hundsun.cprs.yyt.service.trade.domain.query.TradeEntrustQuery;

public interface TradeEntrustDao {
    int deleteByPrimaryKey(Long id);

    int insert(TradeEntrust record);

    int insertSelective(TradeEntrust record);

    TradeEntrust selectByPrimaryKey(Long id);
    
    List<TradeEntrust> selectByQuery(TradeEntrustQuery query);

    TradeEntrust selectByEntrustNo(Long entrustNo);

    int updateByPrimaryKeySelective(TradeEntrust record);

    int updateByPrimaryKey(TradeEntrust record);
    
    int updateEntrustStatus(@Param("entrust") TradeEntrust entrust,@Param("expectEntrustStatus") Integer expectEntrustStatus);
    
    int batchUpdate(List<TradeEntrust> entrusts);
    
    long getEntrustNoFromSequence();

    String getCommitedQuantitySumByGoodsId(Long goodsId);
    
    long getTradeQuantitySumByQuery(TradeEntrustQuery query);

    /**
     * 获取某个用户最新的挂售单
     * @param userId
     *
     * */
    TradeEntrust getUserLastedTradeEntrust(Long userId);

    /**
     * 根据订单编号查委托单详情
     * @param orderSn
     *
     * */
    TradeEntrust getTradeEntrustByOrderSn(String orderSn);

    /**
     * 查询待审核的挂售单列表
     * @param query
     *
     * */
    List<TradeEntrust> selectAuditByPage(TradeEntrustQuery query);

    /**
     * 批量插入委托单
     * @param datas
     * */
    int batchInsert(@Param("datas") List<TradeEntrust> datas);

    /**
     * 根据指定搜索条件查找挂售单
     * 主要用于批量导入审核功能,返回结果集按委托时间倒叙，主键id升序
     * @param request
     * */
    List<TradeEntrust> getAuditListByQuery(@Param("request") AuditRequest request);
}